<?php
$params = array_merge(
    require __DIR__ . '/../../common/config/params.php',
    require __DIR__ . '/../../common/config/params-local.php',
    require __DIR__ . '/params.php',
    require __DIR__ . '/params-local.php'
);

return [
    'id' => 'ym2_backend',
    'name' => 'yii manager 2.0',
    'basePath' => dirname(__DIR__),
    'controllerNamespace' => 'backend\controllers',
    'language' => 'zh-CN',
    'sourceLanguage' => 'en-US',
    'bootstrap' => ['log', 'viewBuilder'],
    'modules' => [],
    //'catchAll' => ['shutdown/index'], //关停站点
    'defaultRoute' => 'home/index',
    'as beforeActionBehaviors' => 'common\behaviors\backend\BeforeActionBehaviors',
    'components' => [
        // 视图构建器2.0.0
        'viewBuilder' => [
            'class' => 'builder\ViewBuilder',
        ],
        // RBAC管理器
        'rbacManager' => [
            'class' => 'common\components\RbacManager',
        ],
        'request' => [
            'csrfParam' => '_ym2_csrf_backend',
        ],
        'response' => [
            'on beforeSend' => [new \common\handlers\backend\BeforeResponseSetCookie(), 'run'],
        ],
        'view' => [
            'class' => 'yii\web\View',
            'on beforeRender' => [new \common\handlers\backend\BeforeRenderDynamicUpdateViewParams(), 'run'],
            'params' => [
                /** 视图主题 */
                'uiTheme' => 'ym2-theme-black',
                'themeColor' => '#00b6bf',
                /** 左侧导航菜单是否默认展开 */
                'asideExpanded' => true,
                /** 左侧导航菜单默认布局 list：列表 grid：网格*/
                'menuLayout' => 'list',
            ],
        ],
        'user' => [
            'class' => 'yii\web\User',
            'accessChecker' => 'rbacManager',
            'identityClass' => 'common\models\Admin',

            'enableAutoLogin' => true,//该配置项和authKey只能二选一
            'identityCookie' => ['name' => '_ym2_identity_backend', 'httpOnly' => true],
        ],
        'session' => [
            // this is the name of the session cookie used for login on the backend
            'name' => '_ym2_backend',
            'savePath' => '@root/sess/backend',
            'timeout' => 12 * 3600,
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'errorHandler' => [
            'errorAction' => 'error/index',
        ],

        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
            ],
        ],

    ],
    'params' => $params,
];
